import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
// import Cookie from "js-cookie";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home
  },
  {
    path: "/login",
    name: "Login",
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/Login.vue"),
  },
  {
    path: '/reset',
        name: 'Reset',
        //当用户访问对应的组件时，才会调用回调函数加载该组件
        //懒加载导入模块1
        component: () => import("../views/Reset.vue"),
  },
  {
    path: "/firstPage",
    name: "FirstPage",
    redirect: "/indexPage",
    children: [{
        path: '/indexPage',
        name: "IndexPage",
        component: () =>
          import("../views/IndexPage.vue"),
        //路由原信息
      },
      {
        path: "/about",
        name: "About",
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () =>
          import( /* webpackChunkName: "about" */ "../views/About.vue")
      },
    ],
    component: () =>
      import( /* webpackChunkName: "about" */ "../views/FirstPage.vue")
  },
  {
    path: "/foodType",
    name: "FoodType",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import( /* webpackChunkName: "about" */ "../views/FoodType.vue")
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
